#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

typedef char TNDataType;
typedef struct TreeNode
{
    TNDataType val;
    struct TreeNode* left;
    struct TreeNode* right;
}TreeNode;

TreeNode* BuyNode(TNDataType x)
{
    TreeNode* node = (TreeNode*)malloc(sizeof(TreeNode));
    if (node == NULL)
    {
        perror("BuyNode->malloc");
        exit(-1);
    }
    node->left = node->right = NULL;
    node->val = x;
    return node;

}

TreeNode* CreatTree(const char* str, int* pi)
{
    if (str[*pi] == '#')
    {
        (*pi)++;
        return NULL;
    }

    TreeNode* root = BuyNode(str[(*pi)++]);

    root->left = CreatTree(str, pi);
    root->right = CreatTree(str, pi);
    return root;
}

void InOrder(TreeNode* root)
{
    if (root == NULL) return;

    InOrder(root->left);
    printf("%c ", root->val);
    InOrder(root->right);

}
int main()
{
    char str[101];
    scanf("%s", str);
    int i = 0;

    TreeNode* root = CreatTree(str, &i);

    InOrder(root);
    return 0;
}